package com.wh.org.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ser.Serializers;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 实体类：部门
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("t_department")    //表示关联哪张表，如果不写，默认关联和实体类名一致的表。
public class Department implements Serializable {

    @TableId(value = "id",type = IdType.AUTO)
    //部门ID
    private Long id;
    //部门编号
    private String sn;
    //部门名称
    private String name;
    //部门路径
    @TableField("dirPath")
    private String dirPath;
    //部门状态：1启用,0禁用
    private Integer state = 1;
    //部门经理ID
    private Long managerId;
    //上级部门ID
    private Long parentId;

    //部门经理信息
    @TableField(exist = false)
    private  Employee depManage;
    //部门信息
    @TableField(exist = false)
    private Department parent;


    //用于封装当前部门的子部门 属性名字必须是children
    @TableField(exist = false)
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<Department> children =new ArrayList<>();
}